﻿using System;

namespace ChatServer
{
    public class User
    {
        /// <summary>
        /// Create a new instance of User
        /// </summary>
        public User() { }
        /// <summary>
        /// Create a new instance of User
        /// </summary>
        public User(String name) : this(name, Status.Online) { }
        /// <summary>
        /// Create a new instance of User
        /// </summary>
        public User(String name, Status status)
        {
            bool unique = true;
            int id;
            do
            {
                id = new Random().Next(1, int.MaxValue);
                foreach (User user in new ChatServices().GetUsers())
                    unique = user.UserID != id;              
            } while (!unique);

            UserID = id;
            Name = name;
            Status = status;
        }

        /// <summary>
        /// The ID of the user
        /// </summary>
        public int UserID { get; set; }

        /// <summary>
        /// Name of the user
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// Status of the user
        /// </summary>
        public Status Status { get; set; }
    }
}
